<template>
  <div>
    <el-table :data="list" border style="width: 100%;margin-top: 15px;">
      <el-table-column prop="name" label="任务名"></el-table-column>
      <el-table-column prop="dir" label="项目根目录"></el-table-column>
      <el-table-column
        prop="buildCommond"
        label="打包命令"
      ></el-table-column>
      <el-table-column
        prop="otherCommond"
        label="其他命令"
      ></el-table-column>
      <el-table-column prop="status" label="状态">
        <template #default="scope">
          {{ statusList?.[scope.row.status] || "" }}
        </template>
      </el-table-column>
      <el-table-column label="服务器配置" width="200">
        <template #default="scope">
          <div style="max-height: 150px; overflow: auto">
            <div v-for="(value, key) in scope.row">{{ key }}: {{ value }}</div>
          </div>
        </template>
      </el-table-column>
      <!-- <el-table-column label="操作" width="180">
        <template #default="scope">
          <el-button link type="primary" @click="start">开始</el-button>
        </template>
      </el-table-column> -->
    </el-table>
  </div>
</template>
<script setup>
import { ref } from "vue";
const list = ref([]);
const statusList = ref(["无", "待执行", "执行中等待中", "执行中", "执行完成"])

const emit = defineEmits(["updateConfig"]);
// 获取待执行任务列表
const init = async () => {
  const result = await window.pywebview.api.getJobListByStatusList(["2","3"]);
  if(result.code === 200) {
    list.value = result.data
  }else {
    ElMessage.error(result.msg);
  }
}
init()

setInterval(init, 1000)

// 将方法暴露给父组件
defineExpose({
  init
});
</script>

